---
layout: "default"
title: "last"
description: "Swift documentation for 'last': Returns the last element of x, or nil if x is empty."
keywords: "last,func,swift,documentation"
root: "/v1.2"
---

<div class="declaration" id="func-last-c_-collectiontype-where-c-index_-bidirectionalindextype_-c">
<a class="toggle-link" data-toggle="collapse" href="#comment-func-last-c_-collectiontype-where-c-index_-bidirectionalindextype_-c">func <wbr>last&lt;C :<wbr> CollectionType where C.Index : BidirectionalIndexType&gt;(<wbr>_: C)</a>
        
<div class="comment collapse" id="comment-func-last-c_-collectiontype-where-c-index_-bidirectionalindextype_-c"><div class="p">
    <p>Returns the last element of <code>x</code>, or <code>nil</code> if <code>x</code> is empty.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">func last&lt;C : CollectionType where C.Index : BidirectionalIndexType&gt;(x: C) -&gt; C.Generator.Element?</code>
    
    
</div></div>
</div>
